 $(function(){
 	//密码验证
    $("#password").blur(function(){
    	console.log("111111111");
    	var pwd1=$("#password").val();
    	if(pwd1==''){
    		$(".input_xx").css({"display":"block"});
        	$(".input_xx p").html("密码不能为空");
        	$(".input_xx p").css({"color":"#F00"});
        }else if(pwd1.length<6){
        	$(".input_xx").css({"display":"block"});
			$(".input_xx p").html("密码不能少于6位");
			$(".input_xx p").css({"color":"#F00"});
		}else if(pwd1.length>15){
			$(".input_xx").css({"display":"block"});
			$(".input_xx p").html("密码不能大于15位");
			$(".input_xx p").css({"color":"#F00"});
		}else{
			$(".input_xx").css({"display":"none"});
			
		}
    });
    //用户名验证
    var flag=false;
    $("#username").blur(function(e){
	var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	var email=$("#username").val();
	isMobilePhone(email);
	if(email==''||flag){
		if(flag){
			$(".input_x").css({"display":"none"});
		}else{
			$(".input_x").css({"display":"block"});
			$(".input_x p").html("邮箱不能为空");
			$(".input_x p").css({"color":"#F00"});
		}
	}else if(!pattern.test(email)){
		$(".input_x").css({"display":"block"});
		$(".input_x p").html("邮箱格式错误");
		$(".input_x p").css({"color":"#F00"});
	}else{
	$(".input_x").hide();
	} 
	});
	
	function isMobilePhone(value) {
    	if(value.search(/^(\+\d{2,3})?\d{11}$/) == -1){
        	return flag;
    	}else{
        	return flag=true;
    	}
    }
   (jQuery.fn.Validate=function(yonghu,shuchu){
   	    var flag=false;
   		var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
		var email=$(yonghu).val();
		$.isMobiliPhones(email);
		if(email==''||flag){
			if(flag){
				$(shuchu).css({"display":"none"});
			}else{
				$(shuchu).css({"display":"block"});
				$(shuchu).html("邮箱不能为空");
				$(shuchu).css({"color":"#F00"});
			}
		}else if(!pattern.test(email)){
			$(shuchu).css({"display":"block"});
			$(shuchu).html("邮箱格式错误");
			$(shuchu).css({"color":"#F00"});
		}else{
			$(shuchu).hide();
		} 
  	});
   (jQuery.fn.isMobilePhones=function(value){
   		if(value.search(/^(\+\d{2,3})?\d{11}$/) == -1){
        	return flag;
    	}else{
        	return flag=true;
    	}
   });
});
 
 